#include<iostream>
#include<unistd.h>
#include<pthread.h>

using namespace std;

void* threadHandler1(void* args)
{
    while (true)
    {
        cout << "我是次线程1，我正在运行..." << endl;
        sleep(1);
    }
}

void *threadHandler2(void *args)
{
    while (true)
    {
        cout << "我是次线程2，我正在运行..." << endl;
        sleep(1);
    }
}

void *threadHandler3(void *args)
{
    while (true)
    {
        cout << "我是次线程3，我正在运行..." << endl;
        sleep(1);
    }
}

int main()
{
    pthread_t t1,t2,t3;//创建3个线程
    pthread_create(&t1,NULL,threadHandler1,NULL);
    pthread_create(&t2,NULL,threadHandler2,NULL);
    pthread_create(&t3,NULL,threadHandler3,NULL);

    // 主线程运行
    while (true)
    {
        cout << "我是主线程" << endl;
        sleep(1);
    }

    return 0;

}